gtk-demo: Fix a crash in the puzzle
authorMatthias Clasen <mclasen@redhat.com>
Mon, 1 Jun 2020 04:10:42 +0000 (00:10 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 1 Jun 2020 04:11:50 +0000 (00:11 -0400)
Avoid a crash when clicking the refresh button
after solving the puzzle.

demos/gtk-demo/sliding_puzzle.c

index 925d9817642b75559124c494f015ffe4c5fdce76..c7897f2dfdb02ebbebb005f589f3a520a56fe069 100644 (file)
@@ -355,11 +355,16 @@ reshuffle (void)
 {
   GtkWidget *grid;
 
-  grid = gtk_aspect_frame_get_child (GTK_ASPECT_FRAME (frame));
   if (solved)
-    start_puzzle (puzzle);
+    {
+      start_puzzle (puzzle);
+      grid = gtk_aspect_frame_get_child (GTK_ASPECT_FRAME (frame));
+    }
   else
-    shuffle_puzzle (grid);
+    {
+      grid = gtk_aspect_frame_get_child (GTK_ASPECT_FRAME (frame));
+      shuffle_puzzle (grid);
+    }
   gtk_widget_grab_focus (grid);
 }